<template>
  <router-view v-slot="{ Component }">
    <keep-alive>
      <component
        :is="Component"
        :key="$route.name"
        v-if="$route.meta.keepAlive"
      />
    </keep-alive>
    <component
      :is="Component"
      :key="$route.name"
      v-if="!$route.meta.keepAlive"
    /> 
  </router-view> 

  <!-- <router-view></router-view> -->
<!--    

    //此处是为添加了keepAlive=true 的路由添加缓存
     <keep-alive>
        <router-view v-if="$route.meta.keepAlive"/>   
     </keep-alive>
 
    //此处是为添加了keepAlive=false 的路由默认不缓存
      <router-view v-if="!$route.meta.keepAlive"/>   
-->
</template>

<script setup>
import { onMounted } from '@vue/runtime-core';
import {useRoute} from 'vue-router'
const route=useRoute()
onMounted(()=>{
  console.log(route.meta.KeepAlive);
})

</script>

<style scoped>
</style>
